package com.atguigu06.polymorphism.exer1;

/**
 * ClassName: GeometricTest
 * Package: com.atguigu06.polymorphism.exer1
 * Description:
 *
 * @Author xiao_qi
 * @Create 2024/9/2 11:02
 * @Version 1.0
 */
public class GeometricTest {
    public  static void main(String[] args){
        GeometricTest test = new GeometricTest();
        GeometricObject g1 = new Circle("蓝色",1.0,2.3);
        GeometricObject g2 = new Circle("蓝色",1.0,2.3);
        test.displayGeometricObject(g1);
        test.displayGeometricObject(g2);
        boolean c2 = test.eqalsArea(g1,g2);
        if (c2 == true){
            System.out.println("面积相同");
        }else{
            System.out.println("面积不同");
        }
//使用匿名对象
        test.displayGeometricObject(new MyRectangle("blue",1.0,2.3,4.5));

    }
    /*
比较两个几何图形的面积是否相等
     * @param g1
     * @param g2
     * @return true:表示面积相等   false:面积不相等


     */
    public boolean eqalsArea(GeometricObject g1,GeometricObject g2){
     return g1.findArea() == g2.findArea();
    }
/*
  显示几何图形的面积
  @param g
 */
    public void displayGeometricObject(GeometricObject g){//GeometricObject g = new Circle("red",1.0,2.3);
        System.out.println("几何图形的面积为：" + g.findArea()); //动态绑定  <---> 静态绑定
    }





}
